package com.example.class_manage.Controller;

import com.example.class_manage.Entity.Howework_pic;
import com.example.class_manage.Mapper.HomeWork_pic_mapper;
import com.example.class_manage.Util.JsonData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;

@Slf4j
@RequestMapping("/Howework_pic")
@RestController
@Api(tags = "照片作业接口")
public class HomeWork_pic_Controller {
@Autowired
HomeWork_pic_mapper homeWork_pic_mapper;

@ApiOperation("查询所有写完的照片作业")
@GetMapping("/FindAll_HomeWork_pic")
public JsonData GetAll_HomeWork()
{
    List<Howework_pic> Result = homeWork_pic_mapper.Find_AllHomework();
    return JsonData.buildSuccess(Result,"查询成功");
}

    @ApiOperation("查询此次所有作业通过作业号")
    @GetMapping("/Get_Class_HomeWork_pic")
    public JsonData Get_Class_HomeWork_pic(
            @ApiParam(value = "作业id",required = true)@RequestParam String id
) {
        List<Howework_pic> howework_pics = homeWork_pic_mapper.Get_Class_HomeWork_pic(id);
        if (howework_pics.size() == 0) {
            return JsonData.buildError("无此次作业,请检查作业id");
        } else
            return JsonData.buildSuccess(howework_pics, "查询此次作业成功");
    }

    @ApiOperation("查找助教需要批阅的作业")
    @GetMapping("/Homework_pic_bymark_assistant")
    public JsonData Homework_pic_bymark_assistant(@ApiParam(value = "作业id",required = true)@RequestParam String id
    ) {
        List<Howework_pic> homework_pic_assiatant = homeWork_pic_mapper.Review_All_pic_bymark_flag_assistant(id);
        return homework_pic_assiatant != null ? JsonData.buildSuccess(homework_pic_assiatant, "作业查询成功") : JsonData.buildError("查询失败");
    }


    @ApiOperation("查找老师需要批阅的作业")
    @GetMapping("/Homework_pic_bymark_teacher")
    public JsonData Homework_pic_bymark_teacher() {

        List<Howework_pic> homework_pic_teacher = homeWork_pic_mapper.Review_All_pic_bymark_flag_teacher();
        return homework_pic_teacher != null ? JsonData.buildSuccess(homework_pic_teacher, "作业查询成功") : JsonData.buildError("查询失败");

    }

    @ApiOperation("设置批阅方式")
    @GetMapping("/Up_pic_mark")
    public JsonData Up_pic_mark(
            @ApiParam(value = "批阅标记", required = true) @RequestParam String mark_flag,

            @ApiParam(value = "作业Id", required = true) @RequestParam String id
    ) {
        Integer statu = 0;
        statu = homeWork_pic_mapper.UpHomework_pic_mark(mark_flag, id);
        return statu != 0 ? JsonData.buildSuccess("标记成功") : JsonData.buildError("标记失败");
    }
    @ApiOperation("查找学生需要批阅的作业")
    @GetMapping("/Homework_text_bymark_student")
    public JsonData Homework_text_bymark_student(
            @ApiParam(value = "批阅标记", required = true) @RequestParam String mark_flag) {

        List<Howework_pic> homework_pic_student = homeWork_pic_mapper.Review_All_pic_bymark_flag(mark_flag);
        return homework_pic_student != null ? JsonData.buildSuccess(homework_pic_student, "作业查询成功") : JsonData.buildError("查询失败");
    }


}
